<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>差评管理</title>
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<style type="text/css">
body {font-size: 14px;padding: 20px;}
#condition{line-height: 34px;}
#condition .radio{line-height: 21px;}
#condition>div.row{margin-bottom: 8px;    margin-left: 3px;}
#condition a{color: black;margin-right: 12px;}
#condition a.cfoucs{color: #1ab394;font-weight: bold;}
.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
.ui-dialog-footer button.ui-dialog-autofocus{background-color: #18a689;border-color: #18a689;}
ol{
  		list-style:none;
  	}
  	li{
  		list-style:none;
  	}
  	.label2{
        	height: 34px;
   text-align-last: center;
    width: 50px;
    margin-left: -210px;
    line-height: 30px;
    background-color: #EAEAEA;
        }
         .label3{
        height: 34px;
   text-align: center;
    background-color: #EAEAEA;
        }
</style>
</head>
<body class="gray-bg">
<div class="container-fluid" style="padding-top: 40px;background-color: white;">
	<form action="" id="badForm">
	<div id="condition">
		<div class="row">
			<div class="col-sm-1">
				会员名称
			</div>
			<div class="col-sm-2">
				<input class="form-control" id="name" value="" style="    margin-left: 10px;">
			</div>
			<div class="col-sm-5"></div>
			
			<div class="col-sm-4 text-center">
				<button class="btn btn-white col-sm-3" type="button" style="border-color: #18a689;" onclick='func_reload()'>重置</button>
				<div class="col-sm-1"></div>
				<button class="btn btn-primary col-sm-3" type="button" id="commit">查询</button>
		</div>
		</div>
		<div class="row">
		<div class="col-sm-1">
				会员手机号
			</div>
			<div class="col-sm-2">
				<input class="form-control" id="phone" style="    margin-left: 10px;">
			</div>
		</div>
		<div class="row">
			<div class="col-sm-1">
				评价时间：
			</div>
			<div class="col-sm-1" style="padding-left: 24px;width: 100px;">
			<div class="radio radio-primary">
	                <input id="now" type="radio" name="time" value="今天" checked="checked" onclick='func_timeHiden()'>
	                <label for="now">今天</label>
	            </div>
	        </div>
	        <div class="col-sm-1" style="padding-left: 0;width: 70px;">
	            <div class="radio radio-primary">
	                <input id="yesterday"type="radio" name="time" value="昨天" onclick='func_timeHiden()'>
	                <label for="yesterday">昨天</label>
	            </div>
	        </div>
	        <div class="col-sm-1"style="padding-left: 0;width: 70px;">
	            <div class="radio radio-primary">
	                <input id="nowMonth" type="radio" name="time" value="本月" onclick='func_timeHiden()'>
	                <label for="nowMonth">本月</label>
	            </div>
	        </div>
	        <div class="col-sm-1"style="padding-left: 0;width: 70px;">
	            <div class="radio radio-primary">
	                <input id="shang" type="radio" name="time" value="上月" onclick='func_timeHiden()'>
	                <label for="shang">上月</label>
	            </div>
	        </div>
	       <div class="col-sm-1" style="padding-left: 0;width: 70px;">
	            <div class="radio radio-primary" >
	                <input id="none"type="radio" name="time" value="其他"  onclick='func_timeShow()'>
	                <label for="none">其他</label>
	            </div>
	        </div>
	        <div class="input-daterange date input-group" id="datepicker">
					<input type="text" class="input-sm form-control" name="date" value="2017-01-01" id="startDate" readOnly="readOnly">
                    <span class="input-group-addon" style="height: 24px;">到</span>
                    <input type="text" class="input-sm form-control" name="date" value="2017-12-31" id="endDate" readOnly="readOnly">
                </div>	
		</div>
		<!-- <div class="row">
			<div class="col-sm-1" style="width: 128px;">
				评价时间排序：
			</div>
			<div class="col-sm-1" style="padding-left: 0;width: 111px;">
	            <div class="radio radio-primary">
	                <input id="a" type="radio" name="sex" value="f" checked="checked">
	                <label for="a">从近到远</label>
	            </div>
	        </div>
	        <div class="col-sm-1" style="width: 111px;">
	            <div class="radio radio-primary">
	                <input id="b" type="radio" name="sex" value="m">
	                <label for="b">从远到近</label>
	            </div>
	        </div>
		</div> -->
		<div class="row">
			<div class="col-sm-1" style="width: 128px;">
				服务评价类型：
			</div>
			<div class="col-sm-1" style="padding-left: 0;width: 111px;">
	            <div class="radio radio-primary">
	                <input id="a2" type="radio" name="service" value="药品疗效" checked="checked">
	                <label for="a2">药品疗效</label>
	            </div>
	        </div>
	        <div class="col-sm-1" style="width: 111px;">
	            <div class="radio radio-primary">
	                <input id="b2" type="radio" name="service" value="药师服务">
	                <label for="b2">药师服务</label>
	            </div>
	        </div>
	        <div class="col-sm-1" style="width: 111px;">
	            <div class="radio radio-primary">
	                <input id="c2" type="radio" name="service" value="门店服务">
	                <label for="c2">门店服务</label>
	            </div>
	        </div>
	        <div class="col-sm-1" style="width: 111px;">
	            <div class="radio radio-primary">
	                <input id="d2" type="radio" name="service" value="不限">
	                <label for="d2">不限</label>
	            </div>
	        </div>
		</div>
		
	</div>
	</form>
	<div class="form-group">
					<div class="col-sm-12">
						<table class="display table-bordered" id="myTable" style="width:100%">
							<thead>
							 <tr>
								<th>编号</th>
								<th>手机号</th>
								<th>会员名称</th>
								<th>评价时间</th>
								<th>评价内容</th>
								<th>购药信息</th>
								<th>会员绑定</th>
							 </tr>
							</thead>
							<tbody>
								
							</tbody>
						</table>
					</div>
				</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
var name="";
var phone="";
var monthFlag="";
var endDate="";
var startDate="";
var serviceFlag="";
var path = "<%=path%>";
var myDataTable;
var access_token=$.cookie('access_token');
var cid=$.cookie('cid');
var uid=$.cookie('uid');
var orderData;
$(function(){
	$("#condition a").click(function(){
		$(this).addClass("cfoucs").siblings().removeClass("cfoucs");
	});	
	myDataTable=dataTable();
});
function dataTable(){
	return $('#myTable').DataTable({
		processing: true,
		searching: false,
		info: true,
		autoWidth: true,
		lengthChange: false,
	    language: {
	    	emptyTable: '<div id="content_empty"  class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   <p>暂无点击数据</p></div>',
	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
			infoEmpty: '没有数据',
			lengthMenu: '每页显示 _MENU_ 条记录',
			loadingRecords: '正在加载数据....',
			processing: '正在处理数据....',
			zeroRecords: '没有找到匹配的记录',
			paginate: {
				first: '首页',
				previous: '前页',
				next: '后页',
				last: '尾页'
			}
	    },
		pageLength: 6,
	    pagingType: 'full_numbers',        	     
	    columns: func_columns(),
	     columnDefs: [{
	    	　　　　'targets' : [0,1,2,4,5,6],    //除第六，第七两列外，都默认不排序
	    	　　　　'orderable' : false
	    	　　},{
				render: function(data, type, full) {
					var result="<a href='javaScript:void(0)'onclick='func_showMemberDetailDialog("+data.id+")'>"+data.name+"</a>";           
					return result;
					},
				targets: 2
	            },{
			render: function(data, type, full) {
				data=JSON.parse(data);
				var result='<ol>';
				for(var i=0;i<data.length;i++){
					result+="<li>"+data[i].name+":"+func_score(data[i].score)+"</li>";
				} 
				result+="<li><a href='javaScript:void(0)'onclick='func_showEvaluateDetailDialog("+data[0].evaluationId+")'>查看更多</a></li>"
				return result;
				},
			targets: 4
            },{
    			render: function(data, type, full) {
    				data=JSON.parse(data);
    				var result="";
    				var orderUrl="<%=path%>/ser/order/findOrder";
    				$.ajax({
    					url:orderUrl,
    					type:"post",
    					async:false,
    					data:{"id":data},
    					success:function(data){		   					
	    					data=JSON.parse(data);	   					
	    					result+="<ol><li>购药时间:"+data.trade_time+"</li>";
	    					data=JSON.parse(data.goods_name);   	
		    					 for(var i=0;i<data.length;i++){
		    						result+="<li><a onclick='func_medicine("+data[i].goodsId+")'>"+data[i].goodsName+"</a>,"+data[i].purchaseQuantity+"盒</li>";
		    					}
		    					 result+="</ul>";
	    					}
    				});
    				return result;
                },
			targets: 5
		}], 
	    serverSide: true,
	    ajax: {
	    	contentType: 'text/plain;charset=utf-8',
	    	type: 'POST',
	    	url: func_AjaxUrl(),
	    	data: function(d){
				d.extra_search = func_ajaxData();
				return JSON.stringify(d);
	    	}	    	
	    }
	});
	 function func_AjaxUrl(){
     	return path+"/ser/evaluate/getAll";
     }
	 function func_score(score){
		 if(score=="5"){
			 score="非常好";
		 }else if(score=="4"){
			 score="好";
		 }else {
			 score="差";
		 }
		 return score;
	 }
	 $(".cfoucs").click(function(){
		 var time=$(".cfoucs").html();
		 console.log(time);		 
	 });
	 function search_time(){
		 var time=$(".cfoucs").html();
		 console.log(time);		 
	 }
	 /**
	  *	后台查询条件
	  */
	 function func_ajaxData(){
	 	var jsonObject = new Object();
		if(name!=""){
			jsonObject.name=name;
		}
		if(phone!=""){
			jsonObject.phone=phone;
		}
		if(startDate!=""){
			jsonObject.startDate=startDate;
		}
		if(endDate!=""){
			jsonObject.endDate=endDate;
		}
		if(monthFlag!=""){
			jsonObject.monthFlag=monthFlag;
		}
		if(serviceFlag!=""){
			jsonObject.serviceFlag=serviceFlag;
		}
	 	return jsonObject;
	 }
     /**
      *	设置列名，对应后台
      */
     function func_columns(){
     	var jsonArr = [
     		{"data":"order_id"},
     		{"data":"phone"},
     		{"data":"name"},
     		{"data":"create_time"},
     		{"data":"detail"},
     		{"data":"order_id"},
     		{"data":"cashier_name"}
     	];
     	return jsonArr;
     }
}
function func_artdialog(name,value){
	var d = dialog({
		title: name,
		content:value,
		okValue: "确定",
		ok: function () {
			return true;
		}
	});
	d.show();
}
function func_showMemberDetailDialog(memberId) {
    memberDetailDialog = dialog({
        id: "memberDetailDialog",
        fixed: true,
        width: 900,
        height: 400,
        title: '会员详情',
        url: path + "/view/member/member/userInfo?memberId=" + memberId,
        cancel: true,
        cancelValue: "关闭"
    });
    memberDetailDialog.showModal();
    $("iframe[name='memberDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
}
function func_showEvaluateDetailDialog(evaluationId){
	evaluationDetailDialog=dialog({
		id: "evaluationDetailDialog",
        fixed: true,
        width: 400,
        height: 400,
        title: '评价详情',
        url: path + "/ser/ui/showEvaluate?evaluationId=" + evaluationId,
        cancel: true,
        cancelValue: "关闭"
	});
	evaluationDetailDialog.showModal();
	$("iframe[name='memberDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
}
function func_timeShow(){
	//alert(1111);
	//$("input[name='date']").attr("readOnly","1");
	$("input[name='date']").removeAttr("readOnly");
	$(".input-daterange").datepicker({keyboardNavigation:!1,forceParse:!1,autoclose:!0});
}
function func_timeHiden(){
	$("input[name='date']").attr("readOnly","readOnly");
	$(".input-daterange").datepicker('destroy');
	//$("#startDate").attr("readOnly","readOnly");
	//$("#endDate").attr("readOnly","readOnly");
}
function func_searchData(){
	name=$("#name").val();
	phone=$("#phone").val();
	serviceFlag=$('input:radio[name="service"]:checked').val();
	monthFlag=$('input:radio[name="time"]:checked').val();
	startDate=$("#startDate").val();
	endDate=$("#endDate").val();
	if(serviceFlag=="不限"){
		serviceFlag="";
	}
/* 	console.log("---->name"+name);
	console.log("---->phone"+phone);
	console.log("---->serviceFlag"+serviceFlag);
	console.log("---->monthFlag"+monthFlag);
	console.log("---->startDate"+startDate);
	console.log("---->endDate"+endDate); */
}
function func_reload(){
	$("#badForm")[0].reset();
	func_timeHiden();
	/* window.location.reload(); */
	myDataTable.ajax.reload();
}
$("#commit").click(function(){
	func_searchData();
	myDataTable.ajax.reload();
});
function func_medicine(data){
	var name="药品详情";
	var medicineUrl="<%=path%>/ser/evaluate/findById";
	var medicineData;
	var option="";
		$.ajax({
			url:medicineUrl,
			type:"post",
			async:false,
			data:{"id":data},
			success:function(data){				
				medicineData=JSON.parse(data);				
			}
		});
	console.log(medicineData);
	option+="<div style='width:400px;height:400px;overflow-x:scroll;'>";
	option+="<dl class='s_content'>";
	option+="<dt>【药品名称】</dt>";
	option+="<dd>"+medicineData.medicineName+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【药品单位】</dt>";
	option+="<dd>盒</dd></dl>";	
	option+="<dl class='s_content'>";
	option+="<dt>【药品成分】</dt>";
	option+="<dd>"+medicineData.element+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【功能主治】</dt>";
	option+="<dd>"+medicineData.indication+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【用法用量】</dt>";
	option+="<dd>"+medicineData.dosage+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【不良反应】</dt>";
	option+="<dd>"+medicineData.sideEffect+"</dd></dl>";	
	option+="<dl class='s_content'>";
	option+="<dt>【药品禁忌】</dt>";
	option+="<dd>"+medicineData.contraindication+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【注意事项】</dt>";
	option+="<dd>"+medicineData.precaution+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【药品贮藏】</dt>";
	option+="<dd>"+medicineData.storage+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【有效期】</dt>";
	option+="<dd>"+medicineData.periodValid+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【批准文号】</dt>";
	option+="<dd>"+medicineData.numberApproval+"</dd></dl>";
	option+="<dl class='s_content'>";
	option+="<dt>【生产企业】</dt>";
	option+="<dd>"+medicineData.company_name+"</dd></dl>";
	option+="</div>";
	func_artdialog(name,option);
}
</script>
</html>